package control
{
	import model.ModelLocator;
	import flash.events.Event;
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	public class DeleteAShareMarker
	{
		internal var theModel:ModelLocator = ModelLocator.getInstance();
		private var DeleteAShareMarkerRO:RemoteObject;
		public function DeleteAShareMarker()
		{
			DeleteAShareMarkerRO = new RemoteObject();
			DeleteAShareMarkerRO.destination="DeleteAShareMarker";
			DeleteAShareMarkerRO.doDeleteAShareMarker.addEventListener(ResultEvent.RESULT,DeleteAShareMarkerResultHandler);
			DeleteAShareMarkerRO.addEventListener(FaultEvent.FAULT, DeleteAShareMarkerFaultHandler);
		}
		
		public function doDeleteAShareMarker(markerid:String):void
		{
		//	Alert.show("here in delete share");
			DeleteAShareMarkerRO.doDeleteAShareMarker(markerid,theModel.user.user_id);
		}
		
		internal function DeleteAShareMarkerResultHandler(event:ResultEvent):void
		{
				Alert.show("Delete a shared Marker Successfully.");
				theModel.allShowAllShareMarkers = event.result as ArrayCollection;
				//Alert.show(theModel.allDeleteAShareMarker[1]['username']);
				theModel.dispatchEvent(new Event(ModelLocator.DELETE_SHARE_OK));
		}
		
		internal function DeleteAShareMarkerFaultHandler(event:FaultEvent):void
		{
			Alert.show("error occur when delete your marker");
		}
	}
}